package homework03;

public class Request1 extends Thread{
	private int totalnumber;
	Object lock;
	public Request1(int totalnumber,Object lock){
		this.totalnumber=totalnumber;
		this.lock=lock;
	}
	@Override
	public void run() {
		while(true){
			synchronized (lock) {
				if(Demo.number>totalnumber){
					break;
				}else{
					if(Demo.number%3==0&&Demo.number%5==0){
						Demo.number++;
						System.out.print("fizzbuzz,");
						lock.notify();
						continue;
					}if(Demo.number%5==0){
						Demo.number++;
						System.out.print("buzz,");
						lock.notify();
						continue;
					}if(Demo.number%3==0){
						Demo.number++;
						System.out.print("fizz,");
						lock.notify();
						continue;
					}else{
						try {
							lock.wait();
						} catch (InterruptedException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					}
				}
			}
		}
	}


